﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using ZhongheCms.Models;
namespace ZhongheCms.Controllers
{
    public class OrderController : Controller
    {

        public ActionResult Index(int id = 0, string m = "", string f = "", string p = "", string fid = "", string r = "")
        {
            ViewBag.m = m;
            ViewBag.f = f;
            ViewBag.p = p;
            ViewBag.fid = fid;
            ViewBag.r = r;
            if (GswTblUser.CurrentUser == null)
                return RedirectToAction("Login", "Account");
            GswTblUser.CurrentUser.ModuleName = m;
            GswTblUser.CurrentUser.FuncName = f;
            var qry =
               GswTblHotelOrder.Fetch("where CustomerId=" + GswTblUser.CurrentUser.CustomerId +
                                     " order by Id desc");

            return View(qry);
        }
        public ActionResult OrderView(int id, string m = "", string f = "", string p = "", string fid = "", string r = "")
        {
            ViewBag.m = m;
            ViewBag.f = f;
            ViewBag.p = p;
            ViewBag.fid = fid;
            ViewBag.r = r;
            if (GswTblUser.CurrentUser == null)
                return RedirectToAction("Login", "Account");
            GswTblUser.CurrentUser.ModuleName = m;
            GswTblUser.CurrentUser.FuncName = f;
            var qry = GswTblHotelOrder.SingleOrDefault(id);
            return View(qry);
        }
        public ActionResult Delete(int id,string m = "", string f = "", string p = "", string fid = "", string r = "")
        {
            ViewBag.m = m;
            ViewBag.f = f;
            ViewBag.p = p;
            ViewBag.fid = fid;
            ViewBag.r = r;
            if (GswTblUser.CurrentUser == null)
                return RedirectToAction("Login", "Account");
            GswTblUser.CurrentUser.ModuleName = m;
            GswTblUser.CurrentUser.FuncName = f;
            GswTblHotelOrder.Delete(id);
            var qry = GswTblHotelOrder.Fetch("where CustomerId=" + GswTblUser.CurrentUser.CustomerId +
                                     " order by Id desc");
            return View("Index", qry);
        }
    }
}
